package com.joysuch.wwyt.edu.enums;

import java.util.Objects;

/**
 * @Author ZhangDong
 * @Date 2020/5/28 16:52
 */
public enum CertificateRemindTypes {

    ONE_WEEK(1 * 7 * 24, 7, "提前一周"),
    ONE_MONTH(1 * 30 * 24, 30, "提前一个月"),
    THREE_MONTH(3 * 30 * 24, 3 * 30, "提前三个月"),
    HALF_YEAR(183 * 24, 183, "提前半年"),
    ONE_YEAR(365 * 24, 365, "提前一年");

    private Integer hours;
    private Integer days;
    private String type;

    CertificateRemindTypes(Integer hours, Integer days, String type) {
        this.hours = hours;
        this.days = days;
        this.type = type;
    }

    public static Integer getHours(String type) {
        CertificateRemindTypes[] values = CertificateRemindTypes.values();
        for (CertificateRemindTypes value : values) {
            if (Objects.equals(value.type, type)) {
                return value.hours;
            }
        }
        return null;
    }

    public static Integer getDays(String type) {
        CertificateRemindTypes[] values = CertificateRemindTypes.values();
        for (CertificateRemindTypes value : values) {
            if (Objects.equals(value.type, type)) {
                return value.days;
            }
        }
        return null;
    }

    public static boolean hasType(String type){
        CertificateRemindTypes[] values = CertificateRemindTypes.values();
        for (CertificateRemindTypes value : values) {
            if (Objects.equals(value.type, type)) {
                return true;
            }
        }
        return false;
    }
}
